package com.edu.d1_creat;

public class ThreadDemo2Other {

    /**
     目标：学会线程的创建方式二(匿名内部类方式实现，语法形式)
     */
        public static void main(String[] args) {
            Runnable target = new Runnable() {
                @Override
                public void run() {
                    for (int i = 0; i < 10; i++) {
                        System.out.println("子线程1执行输出：" + i);
                    }
                }
            };
            Thread t = new Thread(target);
            t.start();

            new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int i = 0; i < 10; i++) {
                        System.out.println("子线程2执行输出：" + i);
                    }
                }
            }).start();

            new Thread(() -> {
                for (int i = 0; i < 10; i++) {
                    System.out.println("子线程3执行输出：" + i);
                }
            }).start();

            for (int i = 0; i < 10; i++) {
                System.out.println("主线程执行输出：" + i);
            }
        }
    }

/*
    public static void main(String[] args) {
*/
/*        Runnable target = new Runnable(){
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println("子线程1执行输出：" + i);
                }
            }
        };
        Thread t = new Thread(target);
        t.start();*//*

        new Thread(new Runnable() {
            @Override
            public void run() {

            }
        }).start();

    }
}
*/
